package com.email.util;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

import com.weibo.entity.JianceWeiboText;
import com.weibo.service.JianceService;

public class TestNew {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//当天日期
		int y,m,d,h,mi,s;      
		Calendar cal=Calendar.getInstance();    
		y=cal.get(Calendar.YEAR);    
		m=cal.get(Calendar.MONTH);    
		d=cal.get(Calendar.DATE);    
		h=cal.get(Calendar.HOUR_OF_DAY);    
		mi=cal.get(Calendar.MINUTE);    
		s=cal.get(Calendar.SECOND);    
		System.out.println("现在时刻是"+y+"年"+m+"月"+d+"日"+h+"时"+mi+"分"+s+"秒");    
		JianceService js = new JianceService();
		List<JianceWeiboText> wbs = js.list();
		String text = "";
		for(JianceWeiboText wb : wbs){
			text = text + "<tr style='font-size: 16px'><td colspan='2' valign='middle'>【"+wb.getWeibo_name()+"】 "+wb.getText()+"<br/>" +
			   		"<a href='http://weibo.com/"+wb.getWeibo_id()+"/"+wb.getUrl()+"' style='color:#0000CC; text-decoration:underline;'>点击查看</a><br>" +
			   	"</td>"+"</tr><tr ><td>&nbsp;</td></tr>";
	   	}
		
		EmailMessage emailMessage = new EmailMessage();
		StringBuffer content = new StringBuffer();
		content.append("<table width='700' border='0' cellspacing='0' cellpadding='0'><tbody>"+
					   "<tr><td colspan='2'><h1><img src='http://ww4.sinaimg.cn/mw690/c7356cd4jw1e5qd4on7bpj20jg021t8t.jpg' border='0'/></h1></td></tr><tr>"+
					   	"<td height='40' colspan='2' valign='middle'><p style='color: #fe6007'><strong>下午好。<br />"+
					   	"【发送时间"+m+"月"+d+"日"+h+"时"+mi+"分"+"，监测时间："+m+"月"+d+"日"+" 00:00-24:00】</strong></p><br></td></tr>" +
						text+
						"<tr><td height='35' colspan='2' style='border-top:1px solid #EDEDED;padding-left:10px;'><span style='font-size:14px; font-weight:bold; color:#f60;'>万里云信息管理系统</span></td></tr>"+
						"</tbody></table>");
		emailMessage.setContent(content.toString());
		emailMessage.setFrom("nestor@aliyun.com");
		emailMessage.setPassword("wo4heike");
		emailMessage.setPort(25);
		emailMessage.setServer("smtp.aliyun.com");
		emailMessage.setSubject(m+"/"+d+"daily report");
		emailMessage.setTo("791061133@qq.com");
		emailMessage.setUserName("nestor@aliyun.com");
		SmtpEmail smtpEmail = new SmtpEmail();
		smtpEmail.sendEmail(emailMessage);
		
	}

}
